import { http } from "@/utils/http";
import type { HttpResponse } from "types/request";
import type { NotificationHistory } from "@/types/notification.types";

import { URL_PREFIX } from "./constants";

/**
 * Get notification history from backend
 * @returns Promise with notification history data
 */
export const getNotificationHistory = () => {
  return http.request<HttpResponse<NotificationHistory>>(
    "get",
    `${URL_PREFIX}/notification/history`,
    {},
    { skipProgress: true }
  );
};

/**
 * Send test email for close stats
 * @param gatewayName - The CTP settings name (gateway name)
 * @param to - Email address(es), comma-separated
 * @returns Promise with response data
 */
export const sendTestEmailCloseStats = (gatewayName: string, to: string) => {
  return http.request<HttpResponse<void>>(
    "post",
    `${URL_PREFIX}/notification/mail/close_stats`,
    {
      data: {
        gateway_name: gatewayName,
        to
      }
    }
  );
};
